import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/discount/res_discount_count_entity.dart';

ResDiscountCountEntity $ResDiscountCountEntityFromJson(Map<String, dynamic> json) {
  final ResDiscountCountEntity resDiscountCountEntity = ResDiscountCountEntity();
  final String? availableCount = jsonConvert.convert<String>(json['availableCount']);
  if (availableCount != null) {
    resDiscountCountEntity.availableCount = availableCount;
  }
  final int? couponOverlayLimit = jsonConvert.convert<int>(json['couponOverlayLimit']);
  if (couponOverlayLimit != null) {
    resDiscountCountEntity.couponOverlayLimit = couponOverlayLimit;
  }
  final String? discountMaxAmount = jsonConvert.convert<String>(json['discountMaxAmount']);
  if (discountMaxAmount != null) {
    resDiscountCountEntity.discountMaxAmount = discountMaxAmount;
  }
  final int? storeGoodsCouponConfig = jsonConvert.convert<int>(json['storeGoodsCouponConfig']);
  if (storeGoodsCouponConfig != null) {
    resDiscountCountEntity.storeGoodsCouponConfig = storeGoodsCouponConfig;
  }
  final String? unavailableCount = jsonConvert.convert<String>(json['unavailableCount']);
  if (unavailableCount != null) {
    resDiscountCountEntity.unavailableCount = unavailableCount;
  }
  return resDiscountCountEntity;
}

Map<String, dynamic> $ResDiscountCountEntityToJson(ResDiscountCountEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['availableCount'] = entity.availableCount;
  data['couponOverlayLimit'] = entity.couponOverlayLimit;
  data['discountMaxAmount'] = entity.discountMaxAmount;
  data['storeGoodsCouponConfig'] = entity.storeGoodsCouponConfig;
  data['unavailableCount'] = entity.unavailableCount;
  return data;
}

extension ResDiscountCountEntityExtension on ResDiscountCountEntity {
  ResDiscountCountEntity copyWith({
    String? availableCount,
    int? couponOverlayLimit,
    String? discountMaxAmount,
    int? storeGoodsCouponConfig,
    String? unavailableCount,
  }) {
    return ResDiscountCountEntity()
      ..availableCount = availableCount ?? this.availableCount
      ..couponOverlayLimit = couponOverlayLimit ?? this.couponOverlayLimit
      ..discountMaxAmount = discountMaxAmount ?? this.discountMaxAmount
      ..storeGoodsCouponConfig = storeGoodsCouponConfig ?? this.storeGoodsCouponConfig
      ..unavailableCount = unavailableCount ?? this.unavailableCount;
  }
}